]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
polkitAgent: Cancel session after disconnecting signal handlers
authorJonas Dreßler <verdre@v0yd.nl>
Sun, 23 Jun 2019 11:11:58 +0000 (13:11 +0200)
committerFlorian Müllner <fmuellner@gnome.org>
Sat, 16 Nov 2019 11:09:25 +0000 (12:09 +0100)
When cancelling the PolkitAgent session before disconnecting the signal
handlers, we receive a "completed" signal where `gained_authorization`
is set to FALSE, which means we show an error message inside
`_onSessionCompleted()`.

This in turn means we show an error message every time we cancel a
session. In practice this wasn't really relevant so far since we only
destroyed the session when an actual error occurred before. Now that the
dialog supports empty passwords, we also call `_destroySession()` when
the user changes and no longer has a password set, and in this case we
want to cancel the current session without showing an error message.

So to fix this, disconnect the signal handlers before cancelling the
session, which makes sure we don't receive the last "completed" signal
in case we cancelled the session ourselves. This change also allows
removing `this._wasDismissed`.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/829

js/ui/components/polkitAgent.js

index 05d4682cd36b277f24580dc9819962a3d12f19ce..a25d65100315017d91c3ef37f9655b498ad327a3 100644 (file)
@@ -31,7 +31,6 @@ var AuthenticationDialog = GObject.registerClass({
         this.actionId = actionId;
         this.message = body;
         this.userNames = userNames;
-        this._wasDismissed = false;
 
         this._sessionUpdatedId = Main.sessionMode.connect('updated', () => {
             this.visible = !Main.sessionMode.isLocked;
@@ -249,7 +248,7 @@ var AuthenticationDialog = GObject.registerClass({
              * error providing authentication-method specific information),
              * show "Sorry, that didn't work. Please try again."
              */
-            if (!this._errorMessageLabel.visible && !this._wasDismissed) {
+            if (!this._errorMessageLabel.visible) {
                 /* Translators: "that didn't work" refers to the fact that the
                  * requested authentication was not gained; this can happen
                  * because of an authentication error (like invalid password),
@@ -312,14 +311,15 @@ var AuthenticationDialog = GObject.registerClass({
 
     _destroySession(delay = 0) {
         if (this._session) {
-            if (!this._completed)
-                this._session.cancel();
-            this._completed = false;
-
             this._session.disconnect(this._sessionCompletedId);
             this._session.disconnect(this._sessionRequestId);
             this._session.disconnect(this._sessionShowErrorId);
             this._session.disconnect(this._sessionShowInfoId);
+
+            if (!this._completed)
+                this._session.cancel();
+
+            this._completed = false;
             this._session = null;
         }
 
@@ -381,7 +381,6 @@ var AuthenticationDialog = GObject.registerClass({
     }
 
     cancel() {
-        this._wasDismissed = true;
         this.close(global.get_current_time());
         this._emitDone(true);
     }